extends StaticBody2D
@export var texture_rect : TextureRect
@export var player : CharacterBody2D
@export var pos_offset : Vector2
@export var cur_ground_pos : Vector2
@export var bound_unit : int

func _ready() -> void:
	texture_rect = get_node("TextureRect")
	bound_unit = texture_rect.texture.get_width() * texture_rect.scale.x
	var self_pos:Vector2 = global_position
	pos_offset = self_pos - get_player_pos()

func _process(delta: float) -> void:
	var player_x:int = get_player_pos().x
	position.x = player_x / bound_unit * bound_unit + pos_offset.x
#	print("地图位置: ", position.x)
	pass

func get_player_pos() -> Vector2:
	return player.global_position
